package com.sweet.fourtimeoa.service.impl;

import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.sweet.fourtimeoa.mapper.DesktopURLMapper;
import com.sweet.fourtimeoa.pojo.entity.Favorites;
import com.sweet.fourtimeoa.pojo.entity.Roles;
import com.sweet.fourtimeoa.pojo.vo.PageVo;
import com.sweet.fourtimeoa.service.DesktopURLService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class DesktopURLServiceImpl implements DesktopURLService {
    @Autowired
    private DesktopURLMapper desktopURLMapper;
    @Override
    public PageVo<Favorites> queryFavorites(Integer pageNum, Integer pageSize) {
        PageHelper.startPage(pageNum, pageSize);
        Page<Favorites> list =(Page<Favorites>)desktopURLMapper.queryFavorites();
        PageVo<Favorites> pageVo = new PageVo<>();
        pageVo.setPageNum(list.getPageNum());
        pageVo.setPageSize(list.getPageSize());
        pageVo.setTotal(list.getTotal());
        pageVo.setPages(list.getPages());
        pageVo.setList(list.getResult());
        return pageVo;
    }

    @Override
    public void insertFavorites(Favorites favorites) {
        desktopURLMapper.insertFavorites(favorites);
    }

    @Override
    public Favorites queryFavoritesById(Integer favoriteId) {
        return desktopURLMapper.queryFavoritesById(favoriteId);
    }

    @Override
    public void updateFavorites(Favorites favorites) {
        desktopURLMapper.updateFavorites(favorites);
    }

    @Override
    public void deleteFavorites(Integer favoriteId) {
        desktopURLMapper.deleteFavorites(favoriteId);
    }
}
